package com.lw.acl.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lw.acl.entity.Role;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author testjava
 * @since 2020-01-12
 */
public interface RoleMapper extends BaseMapper<Role> {
    //根据用户id查询出所有对应的角色
    @Select( "select * from acl_role where id in(select role_id from acl_user_role where user_id=#{id})" )
    @Results({
            @Result(property = "id",id = true,column = "id"),
            @Result(property = "roleName",column = "role_name"),
            @Result(property = "roleCode",column = "role_code"),
            @Result(property = "roleCode",column = "role_code"),
            @Result(property = "remark",column = "remark"),
            @Result(property = "isDeleted",column = "is_deleted"),
            @Result(property = "gmtCreate",column = "gmt_create"),
            @Result(property = "gmtModified",column = "gmt_modified")
    })
    List<Role> findById(String userId);
}
